//
// StoreNuke.Net -  http://www.storenuke.net
// Copyright (c) 2005
// by Robert J Collins ( info@storenuke.net ) of WillowTree Software, Inc. ( http://www.willowtreesoftware.com )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using StoreNuke.StarterKit.Commerce.Components;

namespace StoreNuke.StarterKit.Commerce.Admin
{
	/// <summary>
	///		Summary description for AdminMenu.
	/// </summary>
	public class AdminMenu : UserControl
	{
		protected LinkButton btnSkins;
		protected LinkButton btnBackToStore;
		protected Label lblParentTitle;
		protected Label Label1;
		protected LinkButton btnStoreInfo;
		protected System.Web.UI.WebControls.LinkButton btnHelp;
		protected System.Web.UI.WebControls.Label lblSpacer2;
		protected System.Web.UI.WebControls.Label lblSpacer3;
		protected System.Web.UI.WebControls.Label lblSpacer4;
		protected System.Web.UI.WebControls.LinkButton btnCategories;
		protected System.Web.UI.WebControls.Label lblSpacer5;
		protected System.Web.UI.WebControls.LinkButton btnProducts;
		protected System.Web.UI.WebControls.Label lblSpacer6;
		protected System.Web.UI.WebControls.LinkButton btnCustomers;
		protected System.Web.UI.WebControls.Label lblSpacer7;
		protected System.Web.UI.WebControls.LinkButton btnReviews;
		public string ParentTitle;

		private void Page_Load(object sender, EventArgs e)
		{
			lblParentTitle.Text = ParentTitle;
			if((Context.User.Identity.Name == "") || (!IsStoreAdmin))
			{
				Response.Redirect("Default.aspx?scid=6");
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnStoreInfo.Click += new System.EventHandler(this.btnStoreInfo_Click);
			this.btnSkins.Click += new System.EventHandler(this.btnSkins_Click);
			this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click);
			this.btnBackToStore.Click += new System.EventHandler(this.btnBackToStore_Click);
			this.btnCategories.Click += new System.EventHandler(this.btnCategories_Click);
			this.btnProducts.Click += new System.EventHandler(this.btnProducts_Click);
			this.btnCustomers.Click += new System.EventHandler(this.btnCustomers_Click);
			this.btnReviews.Click += new System.EventHandler(this.btnReviews_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		public bool IsStoreAdmin
		{
			get{return Security.IsStoreAdmin(Context.User.Identity.Name);}
		}
		
		private void btnBackToStore_Click(object sender, EventArgs e)
		{
			Response.Redirect("Default.aspx");
		}

		private void btnSkins_Click(object sender, EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=2");
		}

		private void btnStoreInfo_Click(object sender, EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=18");
		}

		private void btnHelp_Click(object sender, System.EventArgs e)
		{
			string BuildQuery = "Default.aspx?scid=19";
			if(Request.QueryString["scid"] != null)
			{
				BuildQuery += "&hscid=" + Request.QueryString["scid"];
			}
			else
			{
				BuildQuery += "&hscid=1";
			}
			if(Request.QueryString["ctl"] != null)
				BuildQuery += "&hctl=" + Request.QueryString["ctl"];

			Response.Redirect(BuildQuery);
		}

		private void btnCategories_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=15&sctl=1");
		}

		private void btnProducts_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=3&sctl=1");
		}

		private void btnCustomers_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=20&sctl=1");
		}

		private void btnReviews_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("Default.aspx?scid=10&sctl=1");
		}
	}
}
